import { merge, isFunction, isPlainObject } from 'lodash'
import Table from './index.vue'
Table.createTable = function (option) {
    const that = this
    const h = this.$createElement;
    this.temptable = merge({
        extends: Table
    }, option)
    // 绑定Table配置中this对象
    const bindThis = (obj) => {
        if (!obj) return null
        const bindFunction = (fn) => {
            fn.bind(that)
        }
        if (isFunction(obj)) {
            bindFunction(obj)
        }
        else if (isPlainObject(obj)) {
            for (let key in obj) {
                if (isFunction(obj[key])) {
                    bindFunction(obj[key])
                }
            }
        }
    }
    // bindThis(this.temptable.computed)
    // bindThis(this.temptable.watch)
    // bindThis(this.temptable.methods)
    // bindThis(this.temptable.beforeCreate)
    // bindThis(this.temptable.created)
    // bindThis(this.temptable.mounted)
    // bindThis(this.temptable.beforeDestroy)
    // bindThis(this.temptable.destroyed)
    return <this.temptable singleTable={true} />
}
export default Table